package top.broncho.lottery.db

import androidx.paging.DataSource
import androidx.room.*
import androidx.room.OnConflictStrategy.IGNORE

@Dao
interface LotteryDao {
    @Insert(onConflict = IGNORE)
    suspend fun insert(lotteryEntity: LotteryEntity): Long

    @Update
    suspend fun update(lotteryEntity: LotteryEntity): Int

    @Delete
    suspend fun delete(lotteryEntity: LotteryEntity): Int

    @Query("SELECT * FROM lottery")
    suspend fun getLotteries(): List<LotteryEntity>

    @Query("SELECT * FROM lottery ORDER by _id DESC")
    fun queryLotteries(): DataSource.Factory<Int, LotteryEntity>
}